{
*******************************************************************************
-------------------------------------------------------------------------------
Kliper - next generation multimedia player
Copyright (C) Marcin 'vi4m' Kliks (vi4m@wp.pl)
Copyright (C) Tomasz 'dymsza' Odrobny (dymsza@gmail.com)
-------------------------------------------------------------------------------
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*******************************************************************************
}

unit about;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, strutils, main, utils, defaults;

type
  Taboutform = class(TForm)
    pbox: TPaintBox;
    Timer1: TTimer;
    aboutmemo: TMemo;
    procedure FormShow(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  aboutform: Taboutform;
  mybmp: tbitmap;
  x: integer;
  wait_count: integer;

implementation

{$R *.dfm}

procedure Taboutform.FormShow(Sender: TObject);
var i: integer;
  s: string;
  x, y: integer;
  step: integer;
  text_count: integer;
  margin_top: integer;


begin
  caption := translatestr('KTS_GENERIC_ABOUT');

  wait_count := 0;
  i := 0;
  text_count := 0;
  about.x := 0;
  margin_top := 100;
  mybmp := tbitmap.Create;
  mybmp.PixelFormat := pf24bit;

  mybmp.Width := aboutform.Width;
  mybmp.Canvas.Font.Name := 'Tahoma';
  mybmp.Canvas.Font.Size := 15;
  mybmp.Canvas.Font.Color := clWhite;
  step := mybmp.canvas.textheight('x');
  mybmp.Height := step * aboutmemo.lines.count + margin_top;

  pbox.Canvas.Pen.Color := clGray;
  pbox.Canvas.brush.Color := clBlack;
  mybmp.Canvas.Pen.Color := clGray;
  mybmp.Canvas.Brush.Color := clBlack;
  mybmp.Canvas.FillRect(rect(0, 0, mybmp.Width, mybmp.Height));

  while (text_count < aboutmemo.Lines.Count) do begin

    s := aboutmemo.Lines[text_count];
    s := ansireplacetext(s, '$VERSION', kliper_name);
    s := ansireplacetext(s, '$DATE', kliper_date);
    if pos('Kliper', s) > 0 then begin

      mybmp.Canvas.Font.Style := [fsBold];
    end else

      if pos('Odtwarzacz', s) > 0 then begin

        mybmp.Canvas.Font.Style := [];
      end else

        if pos('[', s) > 0 then begin
          mybmp.Canvas.Font.Color := clGray;
          mybmp.Canvas.Font.Style := [fsBold];
        end
        else
        begin
          mybmp.Canvas.Font.color := clWhite;
          mybmp.Canvas.Font.Style := [];

        end;
    x := mybmp.Canvas.textwidth(s);
    y := mybmp.Canvas.textheight(s);
    if s = '' then inc(i, step);
    mybmp.canvas.TextOUt((mybmp.Width - x) div 2, margin_top + i, s); //(mybmp.Width-x) div 2
    inc(i, y);
    inc(text_count);

  end;

  timer1.Enabled := true;
  SetWindowPos(
    Handle,
    HWND_TOPMOST,
    0,
    0,
    0,
    0,
    SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);
end;

procedure Taboutform.Timer1Timer(Sender: TObject);
var p: array of tpoint;
  a: integer;
  b: pbytearray;
  c: integer;
  fadelen: integer;
begin

  fadelen := 50;
  if x > (mybmp.height - fadelen - 30) then begin
    aboutform.Close;
    exit;
  end;
  if x mod 2 = 0 then begin
    for c := 1 to fadelen do begin
      b := mybmp.ScanLine[x + c];
      for a := 0 to (mybmp.Width - 1) * 3 do begin
        b[a] := round(b[a] * 0.90);
      end;
    end;
    {
    if x + Height + c <= mybmp.Height then begin
      for c := 1 to fadelen do begin
        b := mybmp.ScanLine[x + pbox.height + c];
        for a := 0 to (mybmp.Width - 1) * 3 do begin
          if b[a]=255 then b[a-1]:=255; b[a]:=0; b[a+1]:=255;
        end;
      end;
    end;
    }
  end;
  pbox.Canvas.CopyRect(rect(0, 0, pbox.width, pbox.height + 0), mybmp.canvas, rect(0, x, pbox.width, pbox.height + x));
  inc(x, 1);
  if wait_count < 30 then begin x := 0; inc(wait_count); end;

end;

procedure Taboutform.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  timer1.Enabled := false;
  mybmp.Free;
end;

end.
